package bysj.service;
import bysj.dao.GraduateProjectTypeDao;
import bysj.domain.GraduateProject;
import bysj.domain.GraduateProjectCategory;
import bysj.domain.GraduateProjectType;
import util.JdbcHelper;
import util.Pagination;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

public final class GraduateProjectTypeService {
	private static GraduateProjectTypeDao graduateProjectTypeDao= GraduateProjectTypeDao.getInstance();
	private static GraduateProjectTypeService graduateProjectTypeService= new GraduateProjectTypeService();
	
	public static GraduateProjectTypeService getInstance(){
		return graduateProjectTypeService;
	}

	public Collection<GraduateProjectType> findAll(List conditionList,
											   Pagination pagination) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Collection<GraduateProjectType> graduateProjectTypes =
				graduateProjectTypeDao.finaAll(connection,conditionList,pagination) ;
		JdbcHelper.close(connection);
		return graduateProjectTypes;
	}

	public GraduateProjectType find(Integer id) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		GraduateProjectType graduateProjectType = graduateProjectTypeDao.find(id,connection);
		JdbcHelper.close(connection);
		return graduateProjectType;
	}

	public boolean update(GraduateProjectType graduateProjectType) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Boolean updated = graduateProjectTypeDao.update(graduateProjectType,connection);
		JdbcHelper.close(connection);
		return updated ;
	}

	public Integer add(GraduateProjectType graduateProjectType) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		int add_id = graduateProjectTypeDao.add(graduateProjectType,connection);
		JdbcHelper.close(connection);
		return add_id ;
	}
	public boolean delete(Integer id) throws SQLException{
		Connection connection = JdbcHelper.getConn();
		boolean deleted = graduateProjectTypeDao.delete(id, connection);
		JdbcHelper.close(connection);
		return deleted;
	}
}
